
// 测试域名
// let request_url = "http://www.cf518.vip/xiao.php"

// 正式域名
  let request_url = "https://www.fudai188.com/xiao.php"
function post(method, url , data) {
		return new Promise((resolve, reject) => {
			uni.request({
				url: `${request_url}${url}`,
				data: data,
				method: method,
				success( res ) {
					resolve(res)
				},
				fail( err ) {
					reject("错误信息:" + err)
				}
			})
		})
	}
function getCode() {
		let self = this
		return new Promise((resolve, reject) => {
			uni.login({
				success( res ) {
					resolve(res)
				}
			})
		})
	}
function authPhone( phone ) {
	let reg = /^1[356789]\d{9}$/g
	return reg.test( phone )
}

function getLocaltion() {
	return new Promise((resolve, reject) => {
		uni.getLocation({
			success( res ) {
				resolve(res)
			}
		})
	})
}
function timeFormat( val ) {
	let YYYY = new Date(val).getFullYear()
	let MMMM = new Date(val).getMonth() + 1
	let DDDD = new Date(val).getDate()
	let HH = new Date(val).getHours() 
	let FF = new Date(val).getMinutes()
	return `${YYYY}/${MMMM}/${DDDD} ${HH}时${FF}分`
}
export {post, getCode, authPhone, getLocaltion, timeFormat}